package com.atguigu.jxc.controller;

import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.entity.ReturnList;
import com.atguigu.jxc.service.ReturnListGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.Map;

/**
 * @author fenge
 */
@Controller
@RequestMapping("returnListGoods")
public class ReturnListGoodsController {

    @Autowired
    private ReturnListGoodsService returnListGoodsService;

    @PostMapping("save")
    @ResponseBody
    public ServiceVO save(ReturnList returnList, String returnListGoodsStr, HttpSession session){
        returnListGoodsService.save(returnList,returnListGoodsStr,session);
        return new ServiceVO(100,"请求成功");
    }

    @PostMapping("list")
    @ResponseBody
    public Map<String,Object> list(String returnNumber, Integer supplierId, Integer state, String sTime, String eTime){
        return returnListGoodsService.list(returnNumber,supplierId,state,sTime,eTime);
    }

    @PostMapping("goodsList")
    @ResponseBody
    public Map<String,Object> goodsList(Integer returnListId){
        return returnListGoodsService.goodsList(returnListId);
    }

    @PostMapping("delete")
    @ResponseBody
    public ServiceVO delete(Integer returnListId){
        returnListGoodsService.delete(returnListId);
        return new ServiceVO(100,"请求成功");
    }

    @PostMapping("updateState")
    @ResponseBody
    public ServiceVO updateState(Integer returnListId){
        returnListGoodsService.updateState(returnListId);
        return new ServiceVO(100,"请求成功");
    }

    @PostMapping("count")
    @ResponseBody
    public String count(String sTime, String eTime ,Integer goodsTypeId, String codeOrName){
        return returnListGoodsService.count(sTime,eTime,goodsTypeId,codeOrName);
    }
}
